home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / PowerMacOberon feb96 / Source / Dsp.Mod (.txt) < prev    next >
Encoding:
Oberon Text  |  1995-05-08  |  2.6 KB  |  83 lines  |  [TEXT/.Ob4]

  1. Syntax10.Scn.Fnt
  2. FoldElems
  3. Syntax10.Scn.Fnt
  4. (*----------------------------------------------------------------
  5. Dsp offers screen output in low-level modules that can neither import Out nor Texts.
  6. It directly draws into the right bottom corner of the screen overwriting anything which
  7. is displayed there. If the output area has been filled by Dsp the lines wrap around and
  8. the output goes to the first line of the output area again.
  9. Dsp.Set(x, y)
  10.     sets the top-left corner of the output rectangle (default = (800, 400)).
  11. Dsp.Char(ch)
  12.     writes ch.
  13. Dsp.Ln
  14.     skips to the next line.
  15. Dsp.String(s)
  16.     writes string s.
  17. Dsp.Int(x)
  18.     writes number x with as many digits as necessary.
  19. Dsp.Off
  20.     switches further output off. Anything written with Dsp will be invisible.
  21. Dsp.On
  22.     switches further output on again.
  23. Dsp.Reset
  24.     Clears the output area.
  25. ----------------------------------------------------------------*)
  26. Syntax10i.Scn.Fnt
  27. StampElems
  28. Alloc
  29. 8 May 95
  30. Syntax10b.Scn.Fnt
  31. Documentation
  32. MODULE Dsp;    (* HM 
  33. IMPORT Display, Fonts;
  34.     Y: INTEGER;    (*current base line*)
  35.     X: INTEGER;    (*position of next character in base line*)
  36.     top, left: INTEGER;    (*left margin of current line*)
  37.     on: BOOLEAN;
  38.     fnt: Display.Font;
  39.     dsr, lsp: INTEGER;
  40. PROCEDURE Set* (x, y: INTEGER);
  41. BEGIN left := x; top := y; X := x; Y := y;
  42.     Display.ReplConst(Display.black, left, 1, Display.Width - left - 1, top + dsr + lsp - 1, Display.replace)
  43. END Set;
  44. PROCEDURE Char* (ch: CHAR);
  45.     VAR dx, x, y, w, h: INTEGER; pat: Display.Pattern;
  46. BEGIN
  47.     IF on THEN
  48.         Display.GetChar(fnt, ch, dx, x, y, w, h, pat);
  49.         Display.CopyPattern(Display.white, pat, X + x, Y + y, Display.replace);
  50.         X := X + dx
  51. END Char;
  52. PROCEDURE Ln*;
  53. BEGIN
  54.     IF on THEN
  55.         X := left; Y := Y - lsp;
  56.         IF Y + dsr < 0 THEN Set(left, top) END
  57. END Ln;
  58. PROCEDURE String* (s: ARRAY OF CHAR);
  59.     VAR i: INTEGER;
  60. BEGIN
  61.     i := 0; WHILE s[i] # 0X DO Char(s[i]); INC(i) END
  62. END String;
  63. PROCEDURE Int* (n: LONGINT);
  64.     VAR d: ARRAY 10 OF CHAR; i: INTEGER;
  65. BEGIN
  66.     IF n < 0 THEN Char("-"); n := -n END;
  67.     i := 0; REPEAT d[i] := CHR(30H + n MOD 10); n := n DIV 10; INC(i) UNTIL n = 0;
  68.     REPEAT DEC(i); Char(d[i]) UNTIL i = 0
  69. END Int;
  70. PROCEDURE On*;
  71. BEGIN on := TRUE
  72. END On;
  73. PROCEDURE Off*;
  74. BEGIN on := FALSE
  75. END Off;
  76. PROCEDURE Reset*;
  77. BEGIN Set(left, top)
  78. END Reset;
  79. BEGIN
  80.     fnt := Fonts.Default.raster; lsp := Fonts.Default.height; dsr := Fonts.Default.minY;
  81.     Set(800, 400); Off
  82. END Dsp.
  83.